package com.ruoyi.web.controller.store.pan;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.MoneySettlement;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.IMoneySettlementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author wlmes
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/money/settlement")
@Api(tags = "【请填写功能名称】相关接口")
public class MoneySettlementController extends BaseController {
    @Autowired
    private IMoneySettlementService moneySettlementService;


    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    @ApiOperation("查询【请填写功能名称】列表")
    public TableDataInfo list(MoneySettlement moneySettlement) {
        startPage();
        List<MoneySettlement> list = moneySettlementService.selectMoneySettlementList(moneySettlement);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('money:settlement:export')")
    @GetMapping("/export")
    @ApiOperation("导出【请填写功能名称】列表")
    public AjaxResult export(MoneySettlement moneySettlement) {
        List<MoneySettlement> list = moneySettlementService.selectMoneySettlementList(moneySettlement);
        ExcelUtil<MoneySettlement> util = new ExcelUtil<MoneySettlement>(MoneySettlement.class);
        return util.exportExcel(list, "settlement");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('money:settlement:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取【请填写功能名称】详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(moneySettlementService.selectMoneySettlementById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('money:settlement:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增【请填写功能名称】")
    @RepeatSubmit
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult add(@RequestBody MoneySettlement moneySettlement) {
        moneySettlementService.saveNewMoneySettlement(moneySettlement);
        return AjaxResult.success();
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('money:settlement:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改【请填写功能名称】")
    @RepeatSubmit
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult edit(@RequestBody MoneySettlement moneySettlement) {
        return toAjax(moneySettlementService.updateMoneySettlement(moneySettlement));
    }

    /**
     * 删除【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('money:settlement:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除【请填写功能名称】")
    @RepeatSubmit
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(moneySettlementService.deleteMoneySettlementByIds(ids));
    }
}
